#include<iostream>
#include<queue>

using namespace std;
typedef pair<int,int>pii;//统计 <时间，国家>
queue<pii>q;
const int N = 1e5 + 10;
int st[N];
int n , kinds;

int main()
{
    cin >> n;
    while(n--)
    {
        int t , k; cin >> t >> k;
        for(int i = 1;i <= k;i ++)
        {
            int x; cin >> x;
            q.push({t,x});
            if(st[x]++ == 0) kinds++;
        }
        while(q.size() && q.back().first - q.front().first >= 86400)
        {
            pii tmp = q.front(); q.pop();
            int x = tmp.second;
            if(st[x]-- == 1) kinds--;
        }
        cout << kinds << endl;
    }
    return 0;
}